function feaout=getrs(feain)
feaout=feain;
nnodes=length(feaout.xn);
elements=length(feaout.el);
err1=1e-7;
err2=1e-4;
nr=sqrt(feaout.xn.^2+feaout.yn.^2);
boundarynode=find(abs(nr-feaout.rro)<err2);
nousenode=find(nr-feaout.rri<-err1&nr-feaout.rso>err1);
rotornode=find(abs(nr-feaout.rro)>=err2&nr-feaout.rri>err1);
statornode=find(nr-feaout.rso<-err1);
rbin=find(abs(nr-feaout.rri)<err1);
sbin=find(abs(nr-feaout.rso)<err1);
ttmps=zeros(length(sbin),1);
angins=atan2(feaout.yn(sbin),feaout.xn(sbin));
ms=length(angins);
[tmps,indexts]=sort(angins);
tts=find(angins>=0);
ttmps(1:length(tts))=indexts(ms-length(tts)+1:ms);
ttmps(length(tts)+1:ms)=indexts(1:ms-length(tts));
sbin=sbin(ttmps);
ttmp=zeros(length(rbin),1);
angin=atan2(feaout.yn(rbin),feaout.xn(rbin));
m=length(angin);
[tmp,indext]=sort(angin);
tt=find(angin>=0);
ttmp=find(angin>=0);
ttmp(1:length(tt))=indext(m-length(tt)+1:m);
ttmp=(length(tt)+1:m)=indext(1:m-length(tt));
rbin=rbin(ttmp);
st=length(statornode);
sb=st+length(sbin);
rt=sb+length(rotornode);
rb=rt+length(rbin);
nus=length(nousenode);
temp(1:st)=statornode;
temp(st+1:sb)=sbin;
temp(sb+1:rt)=rotornode;
temp(rt+1:rb)=rbin;
temp(rb+1:rb+nus)=nousenode;
temp(rb+nus+1:nnodes)=boundarynode;
feaout.xn=feaout.xn(temp);
feaout.yn=feaout.yn(temp);
for i=1:elements
    feaout.el(i,1)=find(temp==feaout.el(i,1));
    feaout.el(i,2)=find(temp==feaout.el(i,2));
    feaout.el(i,3)=find(temp==feaout.el(i,3));
end
feaout.st=st;
feaout.sb=sb;
feaout.rt=rt;
feaout.rb=rb;
feaout.nus=nus;
feaout.bounodenum=length(boundarynode);